package memory_usage

import (
	"fmt"
	"runtime"
)

func PrintMemoryUsage(index int) {
	// 主动触发垃圾回收

	var memStats runtime.MemStats
	runtime.ReadMemStats(&memStats)

	fmt.Printf("Memory Usage:%v \n", index)
	fmt.Printf("  Allocated Memory: %d bytes\n", memStats.Alloc)
	fmt.Printf("  Total Memory: %d bytes\n", memStats.Sys)
	fmt.Printf("  Heap Memory: %d bytes\n", memStats.HeapAlloc)
}
